<template>
    <div class="container">
        <div class="header">
            <van-image fit="contain" src="/wxchat/images/xxts.png" />
            <div class="title">
                <span class="text">
                    QC-风险提醒
                </span>
            </div>
        </div>
        <div class="body">
            <van-cell-group v-for="(item, index) in list" :key="index"
                style="margin-bottom: 15px;  background-color: #6F6F6F;">
                <van-cell title="编号" :value="item.partid" />
                <van-cell title="名称" :value="item.partname" />
                <van-cell title="问题" :value="item.type" :label="item.content" />
                <van-cell title="日期" :value="item.createdt" />
            </van-cell-group>
        </div>
    </div>
</template>
<script lang="ts" setup>
import { ref, onMounted } from 'vue'
import { Image as VanImage, Cell as VanCell, CellGroup as VanCellGroup ,showNotify} from 'vant';
import { getRiskApi } from '@/api/index'
import type { risk } from '@/types/data'
import { useRoute } from 'vue-router'
import router from '@/router'

var route = useRoute()
const list = ref<risk[]>([
    // {
    //     partid: '',
    //     partname: '',
    //     type: '',
    //     content: '',
    //     create: ''
    // }
])


// const list = ref<risk>([
//     {
//         partid: 'IT9501-WX',
//         partname: '商用跑步机',
//         type: '一般问题',
//         content: '铁材质量问题',
//         create: '2023-10-12'
//     },
//     {
//         partid: 'IT9502-WX',
//         partname: '家用跑步机',
//         type: '重大风险',
//         content: '铁材质量问题',
//         create: '2023-10-22'
//     }
// ])

onMounted(() => {
    let openid = route?.params.openid
    if (openid) {
        getRiskApi(openid as string).then(({ data }) => {
            console.log(data)
            list.value = data
        }).catch((err) => {
        showNotify(
            { type: 'warning', message: '网路未连接' }
        );
    })
    }
    else {
        router.replace({
            name: '404'
        })
    }
})
</script>
<style lang="scss" scoped></style>